<?=isset($header) ? $header : '' ?>

<!-- Button to trigger modal -->
<link href="/css/bootstrap/dist/css/bootstrap.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="/css/bootstrap/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="/css/bootstrap/js/modal.js"></script>
<script type="text/javascript" src="/css/bootstrap/dist/js/bootstrap.js"></script>


<script type="text/javascript" src="/js/demand.js"></script>
<script type="text/javascript" src="/js/address.js"></script>
<script type="text/javascript" src="/js/demand_pair.js"></script>





<div class="container">
	<?php

	$date = md5(date("Ymdhis"));
	?>
	<input type="hidden" id="ymdhis_mh5" value="<?=$date ?>" >
	<?php
	foreach ($demand_info->result() as $row) {
	?>
	<input type="hidden" id="save_flag" value="false" >
	<form>

		<input type="hidden" name="demand_id" id="demand_id" value="<?=$row -> demand_id; ?>" >
		<input type="hidden" name="type" value="demand_pair_object" >

		<table class="table" id="haha" style="border: black 2px solid; display: none;">

			<tr class="warning">
				<th style="border-bottom: black 2px solid;width:80px; "> 物件類型 </th>

				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;
					width:110px;background-color: white;">

						<input type="radio"  name="_type" value="type_sell" style="margin: 0px 0px 0px 4px;"
						<?=($row -> type_sell == 1) ? 'checked' : '' ?> >
						

						<font color="blue">買賣</font>

						<input type="radio" name="_type" value="type_rent"  style="margin: 0px 0px 0px 4px;"
						<?=($row -> type_rent == 1) ? 'checked' : '' ?> >
						

						<font color="blue">租賃</font>

					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px;margin-left:20px;
					border-style:solid;margin:3px;width:380px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="object_usage_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if (!empty($row -> specify_building1) OR !empty($row -> specify_building2)) {
							echo 'checked';
						}
						?>>
						<font color="blue">物件用途</font>

						<input type="hidden" id="object_usage_flag" name="object_usage_flag" value="<?=($row -> object_usage) ? 'true' : 'false' ?>" >
						<input type="text"   id="object_usage"      name="object_usage"      value="<?=$row -> object_usage ?>"  style="width:270px;margin-left: 13px;"  >
					</div>

				</div></td>
			</tr>

			<tr class="success" >
				<th style="border-bottom: black 2px solid; "> 面積</th>
				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:270px;background-color: white;">
						<input type="checkbox" class="building_area_flag" style="margin: 0px 0px 0px 4px;" value="building_area_flag"
						<?php
						if ($row -> building_area1 > 0 OR $row -> building_area2 > 0) {
							echo 'checked';
						}
						?> >

						<font color="blue">建物面積</font>
						<input type="hidden" name="building_area_flag" id="building_area_flag" style="width:60px;" value="<?=(($row -> building_area1 > 0) OR ($row -> building_area1 > 0)) ? 'true' : 'false' ?>" >
						<input type="text" name="building_area1" id="building_area1" style="width:60px;" value="<?=$row -> building_area1 ?>" >
						~
						<input type="text" name="building_area2" id="building_area2" style="width:60px;" value="<?=$row -> building_area2 ?>" >
						坪
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:270px;max-width:290px;background-color: white;">
						<input type="checkbox"  class="land_area_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> land_area1 > 0 OR $row -> land_area2 > 0) {
							echo 'checked';
						}
						?> >

						<font color="blue">土地面積</font>
						<input type="hidden" name="land_area_flag" id='land_area_flag' value="<?=(($row -> land_area1 > 0) OR ($row -> land_area1 > 0)) ? 'true' : 'false'; ?>" >
						<input type="text"   name="land_area1" id='land_area1' style="width:60px;" value="<?=$row -> land_area1 ?>" >
						~
						<input type="text"   name="land_area2" id='land_area2' style="width:60px;" value="<?=$row -> land_area2 ?>" >
						坪
					</div>
				</div></td>
			</tr>

			<tr class="info">
				<th  style="border-bottom: black 2px solid; ">價格</th>
				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:300px;background-color: white;">
						<input type="checkbox" class="total_budget_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> total_budget1 > 0 OR $row -> total_budget2 > 0) {
							echo 'checked';
						}
						?> >

						<font color="blue">總預算</font>
						<input type="hidden" name="total_budget_flag" id="total_budget_flag"  value="<?=($row -> total_budget1 > 0 OR $row -> total_budget1 > 0) ? 'true' : 'false' ?>" >
						~
						<input type="text" name="total_budget1" id="total_budget1" style="width:70px;margin:0px 10px 0px 10px;" value="<?=$row -> total_budget1 ?>" >
						~
						<input type="text" name="total_budget2" id="total_budget2"style="width:70px;margin:0px 4px 0px 10px;" value="<?=$row -> total_budget2 ?>" >
						萬
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:300px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="budget_per_ping_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> budget_per_ping1 > 0 OR $row -> budget_per_ping2 > 0) {
							echo 'checked';
						}
						?> >
						<font color="blue">每坪預算</font>

						<input type="hidden" name="budget_per_ping_flag" id="budget_per_ping_flag"   value="<?=($row -> budget_per_ping1 > 0 OR $row -> budget_per_ping2 > 0) ? 'true' : 'false' ?>" >
						~
						<input type="text" name="budget_per_ping1" id="budget_per_ping1" style="width:60px;margin:0px 10px 0px 10px;"  value="<?=$row -> budget_per_ping1 ?>" >
						~
						<input type="text" name="budget_per_ping2" id="budget_per_ping2" style="width:60px;margin:0px 4px 0px 10px;"  value="<?=$row -> budget_per_ping2 ?>" >
						萬
					</div>

				</div></td>
			</tr>

			<tr class="warning">
				<th style="border-bottom: black 2px solid;width:60px; "> 區域 </th>

				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;
					width:380px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="key_areas_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if (!empty($row -> key_areas1) OR !empty($row -> key_areas2)) {
							echo 'checked';
						}
						?>
						>
						<font color="blue">重點區域</font>

						<input type="hidden" name="key_areas_flag" id="key_areas_flag" value="<?=($row -> key_areas1 OR $row -> key_areas1) ? 'true' : 'false' ?>" >
						<input type="text" name="key_areas1" id="key_areas1" value="<?=$row -> key_areas1 ?>" style="width:110px;"  onclick="show_emphasis_area('key_areas1')" >
						<input type="text" name="key_areas2" id="key_areas2" value="<?=$row -> key_areas2 ?>" style="width:110px;margin-left: 13px;" onclick="show_emphasis_area('key_areas2')" >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px;margin-left:20px;
					border-style:solid;margin:3px;width:380px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="specify_building_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if (!empty($row -> specify_building1) OR !empty($row -> specify_building2)) {
							echo 'checked';
						}
						?>
						>
						<font color="blue">指定大樓</font>

						<input type="hidden" id="specify_building_flag" name="specify_building_flag" value="<?=($row -> specify_building1 OR $row -> specify_building2) ? 'true' : 'false' ?>" >
						<input type="text" name="specify_building1" id="specify_building1"  value="<?=$row -> specify_building1 ?>"  style="width:110px;"  onclick="show_building_name('specify_building1')" >
						<input type="text" name="specify_building2" id="specify_building2" value="<?=$row -> specify_building2 ?>"  style="width:110px;margin-left: 13px;" onclick="show_building_name('specify_building2')" >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:840px;background-color: white;">

						<input type="checkbox" value="<?//=$row->id ?>" class="sections_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if (!empty($row -> sections1) OR !empty($row -> sections2)) {
							echo 'checked';
						}
						?>
						>

						<font color="blue">路段</font>

						<input type="hidden" id="sections_flag" name="sections_flag" value="<?=($row -> sections1 OR $row -> sections2) ? 'true' : 'false' ?>" >

						<input type="text" name="sections1" id="sections1" value="<?=$row -> sections1 ?>"  style="width:350px;" 					 onclick="show_address('sections1');">

						<input type="text" name="sections2" id="sections2" value="<?=$row -> sections2 ?>"  style="width:350px;margin-left: 13px;" onclick="show_address('sections2');">
					</div>

				</div></td>
			</tr>

			<tr class="success" >
				<th style="border-bottom: black 2px solid; "> 屋況/樓層 </th>

				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:270px;background-color: white;">
						<input type="checkbox" class="year_of_construction_flag" style="margin: 0px 0px 0px 4px;" value="building_area_flag"
						<?php
						if ($row -> year_of_construction  > 0) {
							echo 'checked';
						}
						?> > 
						

						<font color="blue">屋齡</font>
						<input type="hidden" name="year_of_construction_flag"  id="year_of_construction_flag" style="width:60px;" value="<?=($row -> year_of_construction) ? 'true' : 'false' ?>" >
						<input type="text"   name="year_of_construction1"      id="year_of_construction1" style="width:60px;" value="<?=$row -> year_of_construction; ?>" >
						～
						<input type="text"   name="year_of_construction2"      id="year_of_construction2" style="width:60px;" value="<?=$row -> year_of_construction; ?>" >
						年
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:270px;max-width:290px;background-color: white;">
						<input type="checkbox"  class="designated_floors_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> designated_floors1 > 0 OR $row -> designated_floors2 > 0) {
							echo 'checked';
						}
						?> >

						<font color="blue">指定樓層</font>
						<input type="hidden" name="designated_floors_flag" id='designated_floors_flag' value="<?=(($row -> designated_floors1 > 0) OR ($row -> designated_floors2 > 0)) ? 'true' : 'false'; ?>" >
						<input type="text"   name="designated_floors1" id='designated_floors1' style="width:60px;" value="<?=$row -> designated_floors1 ?>" >
						~
						<input type="text"   name="designated_floors2" id='designated_floors2' style="width:60px;" value="<?=$row -> designated_floors2 ?>" >
						層
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:400px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="windows_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if (strlen($row -> windows) > 10) {
							echo 'checked';
						}
						?> >
						<font color="blue">落地窗座向</font>

						<input type="hidden" name="windows_flag" id="windows_flag"  value="<?=(strlen($row -> windows) > 5) ? 'true' : 'false' ?>" >

						<input type="text" name="windows" id="windows" style="width:240px;" value="<?=$row -> windows ?>" >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:400px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="facing_the_household_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if (strlen($row -> facing_the_household) > 10) {
						//if ($row -> facing_the_household > 0) {
							echo 'checked';
						}
						?> >
						<font color="blue">該戶座向</font>
						<input type="hidden" name="facing_the_household_flag" id="facing_the_household_flag"  value="<?=(strlen($row -> facing_the_household) > 5) ? 'true' : 'false' ?>" >
						<input type="text" name="facing_the_household" id="facing_the_household" style="width:240px;" value="<?=$row -> facing_the_household ?>" >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:400px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="building_facing_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if (strlen($row -> facing_the_household) > 10) {
						//if ($row -> facing_the_household > 0) {
							echo 'checked';
						}
						?> >
						<font color="blue">大樓座向</font>

						<input type="hidden" name="building_facing_flag" id="building_facing_flag"  value="<?=(strlen($row -> building_facing) > 5) ? 'true' : 'false' ?>" >
						<input type="text"   name="building_facing"      id="building_facing"       style="width:240px;" value="<?=$row -> building_facing ?>" >
					</div>

				</div></td>
			</tr>

			<tr class="info">
				<th  style="border-bottom: black 2px solid; ">其他</th>
				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:300px;background-color: white;">
						<input type="checkbox" class="parking_number_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> parking_number > 0) {
							echo 'checked';
						}
						?> >

						<font color="blue">車位數</font>
						<input type="hidden" name="parking_number_flag" id="parking_number_flag"  value="<?=($row -> parking_number) ? 'true' : 'false' ?>" >
						<input type="text" name="parking_number" id="parking_number" style="width:70px;margin:0px 10px 0px 10px;" value="<?=$row -> parking_number ?>" >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:300px;background-color: white;">
						<input type="checkbox" class="number_of_rooms_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> number_of_rooms1 > 0 OR $row -> number_of_rooms2 > 0) {
							echo 'checked';
						}
						?> >
						<font color="blue">房數</font>

						<input type="hidden" name="number_of_rooms_flag" id="number_of_rooms_flag"   value="<?=($row -> number_of_rooms1 > 0 OR $row -> number_of_rooms2 > 0) ? 'true' : 'false' ?>" >
						~
						<input type="text" name="number_of_rooms1" id="number_of_rooms1" style="width:60px;margin:0px 10px 0px 10px;"  value="<?=$row -> number_of_rooms1 ?>" >
						~
						<input type="text" name="number_of_rooms2" id="number_of_rooms2" style="width:60px;margin:0px 4px 0px 10px;"  value="<?=$row -> number_of_rooms2 ?>" >
						房
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:300px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="number_of_hall_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> number_of_hall1 > 0 OR $row -> number_of_hall2 > 0) {
							echo 'checked';
						}
						?> >
						<font color="blue">廳數</font>

						<input type="hidden" name="number_of_hall_flag" id="number_of_hall_flag"   value="<?=($row -> number_of_hall2 > 0 OR $row -> number_of_hall1 > 0) ? 'true' : 'false' ?>" >
						~
						<input type="text" name="number_of_hall1" id="number_of_hall1" style="width:60px;margin:0px 10px 0px 10px;"  value="<?=$row -> number_of_hall1 ?>" >
						~
						<input type="text" name="number_of_hall2" id="number_of_hall2" style="width:60px;margin:0px 4px 0px 10px;"  value="<?=$row -> number_of_hall2 ?>" >
						房
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:300px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="number_of_toilet_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> number_of_toilet1 > 0 OR $row -> number_of_toilet2 > 0) {
							echo 'checked';
						}
						?> >
						<font color="blue">衛數</font>

						<input type="hidden" name="number_of_toilet_flag" id="number_of_toilet_flag"   value="<?=($row -> number_of_toilet1 > 0 OR $row -> number_of_toilet2 > 0) ? 'true' : 'false' ?>" >
						~
						<input type="text" name="number_of_toilet1" id="number_of_toilet1" style="width:60px;margin:0px 10px 0px 10px;"  value="<?=$row -> number_of_toilet1 ?>" >
						~
						<input type="text" name="number_of_toilet2" id="number_of_toilet2" style="width:60px;margin:0px 4px 0px 10px;"  value="<?=$row -> number_of_toilet2 ?>" >
						房
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:300px;background-color: white;">
						<input type="checkbox" value="<?//=$row->id ?>" class="number_of_suite_flag" style="margin: 0px 0px 0px 4px;"
						<?php
						if ($row -> number_of_suite1 > 0 OR $row -> number_of_suite2 > 0) {
							echo 'checked';
						}
						?> >
						<font color="blue">套房數</font>

						<input type="hidden" name="number_of_suite_flag" id="number_of_suite_flag"   value="<?=($row -> number_of_suite1 > 0 OR $row -> number_of_suite2 > 0) ? 'true' : 'false' ?>" >
						~
						<input type="text" name="number_of_suite1" id="number_of_suite1" style="width:60px;margin:0px 10px 0px 10px;"  value="<?=$row -> number_of_suite1 ?>" >
						~
						<input type="text" name="number_of_suite2" id="number_of_suite2" style="width:60px;margin:0px 4px 0px 10px;"  value="<?=$row -> number_of_suite2 ?>" >
						房
					</div>

				</div></td>
			</tr>
		</table>
	</form>
	<?php
	}
	?>

	<link rel="stylesheet" href="/js/table/style.css" type="text/css" media="print, projection, screen" />
	<script type="text/javascript" src="/js/table/tablesorter.min.js"></script>

	<script type="text/javascript">
		$(function() {
			$("#tablesorter-demo").tablesorter();
		});
	</script>

	<div style="margin: 0px 0px 10px 0px">
		<button type="button" class="btn btn-success" id="re_pair">
			重新配對
		</button>

		<button type="button" class="btn btn-success" id="save_result">
			儲存結果
		</button>

		<button type="button" class="btn btn-success" id="send_sms">
			發送簡訊
		</button>
		
		<button type="button" class="btn btn-success" id="more">
			進階條件
		</button>
	</div>

	<?php

	//$query = "SELECT count(*) as total FROM member where echelonNumber = '1' and status = '1'";
	//$result = mysqli_query($link,$query);
	//$values = mysqli_fetch_assoc($result);
	//$num_rows = $values['total']; 
	?>

	<div id="content_show" style="float:right;width:100%;">
		<div class="form_style">

			<?=$containers[0] ?>
			<?=$containers[1] ?>
			<?=$containers[2] ?>
			<?=$containers[3] ?>
		</div>
		
		<?php
		//object 跳窗～～＠＠～～＝ ＝wtf～～～～～～～～～～～～～～～～～～～～～～
		foreach($object_modal as $key => $value){
			echo $value;
		}
		
		//Market 跳窗～～＠＠～～＝ ＝wtf～～～～～～～～～～～～～～～～～～～～～～
		foreach($market_modal as $key => $value){
			echo $value;
		}
		?>
	</div>
	
	
	
	
	
	

</div>
<?php
$this->load->view("bootstrap/modal");
?>
<script type="text/javascript">
	$("document").ready(function() {
		
		
		//儲存結果
		$("button#more").click(function() {
			
			$("#haha").toggle();
			
		});
		
		//////////////////////////////////////////
		$("button#send_sms").click(function() {
			var save_flag = $("input#save_flag").val();

			//alert(save_flag);

			if (save_flag == 'false') {

				alert('請先儲存');

			}

			if (save_flag == 'true') {
				//alert('//執行寄簡訊');
				var ymdhis_mh5 = $("#ymdhis_mh5").val();

				$.ajax({
					type : "POST",
					url : "/send_sms/do_send_sms",
					data : {
						'demand_id'  : $("#demand_id").val(),
						'market_ids' : $("#all_market").val(),
						'object_ids' : $("#all_object").val(),
						'content'    : "多筆啦～～",
						//'ymdhis_mh5':ymdhis_mh5
					},
					success : function(data) {
						alert(data);
						//alert("儲存成功");
						////////////////////////////////

						

						/////////////////////////////////

					},
					complete : function(data) {
						//$("#content_show").html('');
						//$("#content_show").html(data);
						//$("#tablesorter-demo").tablesorter();

						//alert(data);
					}
				});

			}
		});

		//儲存結果
		$("button#save_result").click(function() {

			var object_save_id = new Array();
			var market_save_id = new Array();
			var c_i = 0;
			//object
			$("input.object_save_id").each(function() {
				var _val = parseInt($(this).val());
				//alert(_val)
				if (_val >= 1) {
					//alert(_val);
					object_save_id[c_i] = _val;
					c_i = c_i + 1;
				}
			});

			//market
			var mc_i = 0;
			$("input.market_save_id").each(function() {
				//if( $(this).attr('id') == 'disable_market' ){
				//alert($(this).val());
				//if($(this).val()!='undefined')	{
				var m_val = parseInt($(this).val());

				if (m_val >= 1) {
					//alert(m_val);
					market_save_id[mc_i] = m_val;
					mc_i = mc_i + 1;
				}

				//}
			});

			var market_str = '';
			var market_str_flag = true;
			for (key in market_save_id) {

				if (market_str_flag) {
					market_str_flag = false;
					market_str += market_save_id[key];
				} else {
					market_str += "," + market_save_id[key];
				}
			}

			var object_str = '';
			var object_str_flag = true;
			for ( index = 0; index < object_save_id.length; ++index) {

				if (object_str_flag) {
					object_str_flag = false;
					object_str += object_save_id[index];
				} else {
					object_str += "," + object_save_id[index];
				}
			}

			//alert( object_str  +market_str);

			//儲存結果
			//有選到去比對
			var ymdhis_mh5 = $("#ymdhis_mh5").val();
			//ajax start
			$.ajax({
				type : "POST",
				url : "/pair/demand_pair_object_market_result",
				data : {
					'object' : object_str,
					'market' : market_str,
					'demand_id' : $("#demand_id").val(),
					'ymdhis_mh5' : ymdhis_mh5
				},
				success : function(data) {

					$("input#save_flag").val('true');
					alert("儲存成功");

				},
				complete : function(data) {
					//$("#content_show").html('');
					//$("#content_show").html(data);
					//$("#tablesorter-demo").tablesorter();

					//alert(data);
				}
			});
			//ajax end
			///
		});

		//alert( $("#so_many_market").val() );
		//disable
		$("a#disable_object").each(function() {
			$(this).click(function() {
				$(this).parent().parent().html('');
			});
		});
		//disable
		$("a#disable_market").each(function() {
			$(this).click(function() {
				$(this).parent().parent().html('');
			});
		});

		//幹下checkbox
		//對應的＃id就會變化值～true  or  false
		$("input:checkbox").change(function() {

			var _this_id = $(this).attr('class');

			//alert( ' class 的咪拉＝等魚！-> ' + _this_id );

			if ($(this).attr('checked')) {

				$("#" + _this_id).val("true");

			} else {
				$("#" + _this_id).val("false");
			}

		});


		//重新配對！
		$("button#re_pair").click(function() {


			//alert('qweqweqw!!!');


			$("button#send_sms").hide();
			$("button#save_result").hide();
			$("input#save_flag").val('false');
			var _this_class = $(this).attr('class');

			var _verify_code = $("#verify_code").val();
			var _val = $(this).val();

			//有選到去比對
			$.ajax({
				type : "POST",
				url : "/pair/ajax_pair_result",
				data : $("form").serialize(),
				success : function(data) {

					$("#content_show").html('');
					$("#content_show").html(data);
					//$("#tablesorter-demo").tablesorter();

					//alert(data);

					//disable
					$("a#disable_object").each(function() {
						$(this).click(function() {
							var id = $(this).attr("class");
							$(this).parent().parent().html('');
							$("#object_" + id).val('');

						});
					});

					//disable
					$("a#disable_market").each(function() {
						$(this).click(function() {

							var mid = $(this).attr("class");
							$(this).parent().parent().html('');
							$("#market_" + mid).val('');
							//$(this).parent().parent().html('');
						});
					});

				},
				complete : function(data) {
					//$("#content_show").html('');
					//$("#content_show").html(data);
					//$("#tablesorter-demo").tablesorter();

					//alert(data);
				}
			});

		});
	}); 
</script>

<?php
$this -> load -> view('demand/showbox');
$this -> load -> view("showbox/address");

?>


<div style="display: none;">
	
	<form name="form" action="http://smexpress.mitake.com.tw:9600/SmSendPost.asp" method="POST" enctype="multipart/form-data"> 
	
		<input name="encoding" type="hidden" value="utf8" > 
		<input name="username" type="hidden" value="80249881" > 
		<input name="password" type="hidden" value="2uuiajgi" > 
		
		<input name="file" type="file" id="fileToUpload1">
	
		<input id="uploadfile" type="submit" value="upload">  
	</form>
</div>